package com.xiaopeng.common.page;


import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;

/**
 * 分页接口包装类
 * @param <T>
 */
public class PageVO<T>  {

    @Schema(description = "当前页码")
    protected Integer pageNum;

    @Schema(description = "每页行数")
    protected Integer pageSize;

    @Schema(description = "总记录数")
    protected Long totalRows;


    @Schema(description = "总页数")
    protected Integer totalPages;
    @Schema(description = "分页数据")
    private List<T> root;


    /**
     * 设置分页参数
     */
    public <T extends PageVO> T setPageParam(int pageNum, int pageSize, long totalRows, int totalPages) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalRows = totalRows;
        this.totalPages = totalPages;
        return (T) this;
    }

    public Long getTotalRows() {
        return totalRows;
    }

    public <T extends PageVO> T setTotalRows(Long totalRows) {
        this.totalRows = totalRows;
        return (T) this;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public <T extends PageVO> T setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
        return (T) this;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public <T extends PageVO> T setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
        return (T) this;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public <T extends PageVO> T setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return (T) this;
    }

    public List<T> getRoot() {
        return root;
    }

    public void setRoot(List<T> root) {
        this.root = root;
    }
}
